package com.java.multipledatasource.registered;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author hu
 * @version 1.0
 * @date 2020/12/30 0030 下午 2:58
 * @description
 */
@Service
public class UsernameRegisteredParamCheckService  implements RegisteredParamCheckService{

    @Autowired
    private UserService userService;

    @Override
    public boolean checkCode(byte code) {
        return RegisteredEnums.USERNAME.getCode() == code;
    }

    @Override
    public void checkByFieldRules(Object obj) {
        UserNameRegisteredEntity userNameRegisteredEntity = (UserNameRegisteredEntity) obj;
        // todo 校验是否填写
    }

    @Override
    public void checkIsExist(Object obj) {
        UserNameRegisteredEntity userNameRegisteredEntity = (UserNameRegisteredEntity) obj;
        userService.checkByUserName(userNameRegisteredEntity.getUsername());
    }
}
